package com.ruoyi.tzai.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.tzai.mapper.NewsAudioMapper;
import com.ruoyi.tzai.domain.NewsAudio;
import com.ruoyi.tzai.service.INewsAudioService;
import com.ruoyi.common.utils.DateUtils;

/**
 * 音频文件Service业务层处理
 * 
 * @author tzai
 * @date 2025-10-27
 */
@Service
public class NewsAudioServiceImpl implements INewsAudioService 
{
    @Autowired
    private NewsAudioMapper newsAudioMapper;

    /**
     * 查询音频文件
     * 
     * @param audioId 音频文件主键
     * @return 音频文件
     */
    @Override
    public NewsAudio selectNewsAudioByAudioId(Long audioId)
    {
        return newsAudioMapper.selectNewsAudioByAudioId(audioId);
    }

    /**
     * 根据文章ID和语言查询音频文件
     * 
     * @param articleId 文章ID
     * @param language 语言
     * @return 音频文件
     */
    @Override
    public NewsAudio selectNewsAudioByArticleIdAndLanguage(Long articleId, String language)
    {
        return newsAudioMapper.selectNewsAudioByArticleIdAndLanguage(articleId, language);
    }

    /**
     * 查询音频文件列表
     * 
     * @param newsAudio 音频文件
     * @return 音频文件
     */
    @Override
    public List<NewsAudio> selectNewsAudioList(NewsAudio newsAudio)
    {
        return newsAudioMapper.selectNewsAudioList(newsAudio);
    }

    /**
     * 新增音频文件
     * 
     * @param newsAudio 音频文件
     * @return 结果
     */
    @Override
    @Transactional
    public int insertNewsAudio(NewsAudio newsAudio)
    {
        newsAudio.setCreateTime(DateUtils.getNowDate());
        return newsAudioMapper.insertNewsAudio(newsAudio);
    }

    /**
     * 修改音频文件
     * 
     * @param newsAudio 音频文件
     * @return 结果
     */
    @Override
    @Transactional
    public int updateNewsAudio(NewsAudio newsAudio)
    {
        return newsAudioMapper.updateNewsAudio(newsAudio);
    }

    /**
     * 批量删除音频文件
     * 
     * @param audioIds 需要删除的音频文件主键
     * @return 结果
     */
    @Override
    @Transactional
    public int deleteNewsAudioByAudioIds(Long[] audioIds)
    {
        return newsAudioMapper.deleteNewsAudioByAudioIds(audioIds);
    }

    /**
     * 删除音频文件信息
     * 
     * @param audioId 音频文件主键
     * @return 结果
     */
    @Override
    @Transactional
    public int deleteNewsAudioByAudioId(Long audioId)
    {
        return newsAudioMapper.deleteNewsAudioByAudioId(audioId);
    }

    /**
     * 根据文章ID删除音频文件
     * 
     * @param articleId 文章ID
     * @return 结果
     */
    @Override
    @Transactional
    public int deleteNewsAudioByArticleId(Long articleId)
    {
        return newsAudioMapper.deleteNewsAudioByArticleId(articleId);
    }
}

